<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>机器人页面</title>
  {include file='admin_src.html'}
</head>
<body>
    <div class="col-md-12" id="app">
        <div class="col-md-12 text-center robot-title">
                机器人群列表
        </div>
        <div class="table-responsive robot-content">
            <table class="table">
                <tr class="warning">
                    <td>机器人ID</td>
                    <td>群名称</td>
                    <td>群人数</td>
                    <td>通讯ID</td>
                    <td>群头像</td>
                    <td>是否是管理</td>
                    <td>是否禁用(点击更改)</td>

                </tr>
                <tr class="has" v-for="item in robotList.data">
                    <td>{{item.robot_wxid}}</td>
                    <td>{{item.nickname}}</td>
                    <td>{{item.memberCount}}</td>
                    <td>{{item.wxid}}</td>
                    <td><img :src="item.headimgurl" width="45px" height="45px"></td>
                    <td>{{item.isManager==0?'否':'是'}}</td>
                    <td @click="upStatus(item.id,item.status)" style="cursor: pointer">{{item.status==0?'是':'否'}}</td>
                </tr>
            </table>
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <li v-for="(item,i) in robotList.last_page"  class="page-bg"><a href="#" @click="getData((i+1))" >{{i+1}}</a></li>
                    <li style="color: #337ab7;line-height: 34px">&nbsp;&nbsp;当前页数{{page}}页</li>
                </ul>
            </nav>
        </div>

    </div>
</body>
<script>
    var app = new Vue({
        el: '#app',
        data:function() {
            return {
                robotList:[],
                page:1,
            }
        },
        mounted:function(){
            this.getData()
        },
        methods:{
            getData:function (page = 1){
                var that = this;
                this.page = page;
                apiRequest(adminApi.Robot.getGroup,{page:that.page},function (ret){
                    that.robotList = ret;
                })

            },
            upStatus:function (id,status) {
                var that = this;
                var type = 1;
                if(parseInt(status) === 1){
                    type = 0;
                }
                var params = {
                    id:id,
                    status:type,
                }
                apiRequest(adminApi.Robot.setGroup,params,function (ret){
                    coco.init();
                    coco.alert('切换成功');
                    that.getData(that.page)
                })
            }
        }
    })
</script>
</html>